﻿<Window x:Class="XamlHelpmeet.UI.ViewModelCreation.CreateViewModelWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:local="clr-namespace:XamlHelpmeet.UI.ViewModelCreation"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:model="clr-namespace:XamlHelpmeet.Model;assembly=XamlHelpMeet.Model"
        xmlns:scm="clr-namespace:System.ComponentModel;assembly=WindowsBase"
        xmlns:shell="clr-namespace:Microsoft.VisualStudio.Shell;assembly=Microsoft.VisualStudio.Shell.11.0"
        Background="{DynamicResource {x:Static shell:VsBrushes.ToolWindowBackgroundKey}}"
        BorderBrush="{DynamicResource {x:Static shell:VsBrushes.ToolWindowBorderKey}}"
        Foreground="{DynamicResource {x:Static shell:VsBrushes.ToolWindowTextKey}}"
        Title="Create ViewModel"
        Width="593"
        Height="496"
        MinWidth="676"
        MinHeight="530"
        Loaded="CreateViewModelWindow_OnLoaded"
        Unloaded="CreateViewModelWindow_Unloaded"
        WindowStartupLocation="CenterScreen"
        d:DataContext="{d:DesignInstance local:CreateViewModelWindow}"
        mc:Ignorable="d">
    <DockPanel>
        <DockPanel.Resources>
            <CollectionViewSource x:Key="cvsProperties"
                                  Source="{Binding ClassEntity.PropertyInformation}">
                <CollectionViewSource.SortDescriptions>
                    <scm:SortDescription PropertyName="Name" />
                </CollectionViewSource.SortDescriptions>
            </CollectionViewSource>

            <Style TargetType="{x:Type TextBlock}">
                <Setter Property="VerticalAlignment" Value="Center" />
                <Setter Property="HorizontalAlignment" Value="Left" />
            </Style>

            <BooleanToVisibilityConverter x:Key="booleanToVisibilityConverter" />

            <!--  BMK: alternatingWithTriggers style  -->
            <Style x:Key="alternatingWithTriggers"
                   TargetType="{x:Type ListBoxItem}">
                <Style.Triggers>
                    <Trigger Property="ItemsControl.AlternationIndex" Value="1">
                        <Setter Property="Background" Value="WhiteSmoke" />
                    </Trigger>
                </Style.Triggers>
            </Style>
        </DockPanel.Resources>
        <StackPanel Margin="7"
                    HorizontalAlignment="Right"
                    VerticalAlignment="Bottom"
                    DockPanel.Dock="Bottom"
                    Orientation="Horizontal">
            <Button Command="{Binding CreateCommand}"
                    Content="Create"
                    IsDefault="True"
                    Padding="3.5" />
            <Button Margin="7,0,0,0"
                    Click="BtnCancel_Click"
                    Content="Cancel"
                    IsCancel="True"
                    Padding="3.5" />
        </StackPanel>
        <TabControl x:Name="tcPropertyGeneration"
                    BorderThickness="1,1,1,0">
            <TabItem Margin="0"
                     Header="Model Exposure">
                <StackPanel>
                    <TextBlock Margin="7"
                               Text="Configure the model exposure on the view model" />
                    <StackPanel Margin="7"
                                Orientation="Horizontal">
                        <TextBlock FontSize="14"
                                   Text="Data Class" />
                        <TextBlock Margin="7,0,0,0"
                                   FontSize="14"
                                   FontWeight="Bold"
                                   Text="{Binding TypeName}" />
                    </StackPanel>

                    <StackPanel Margin="3.5"
                                Orientation="Horizontal">
                        <TextBlock Foreground="Blue"
                                   Text="{Binding PropertySignature}" />
                        <TextBox Width="200"
                                 Margin="7,0"
                                 Text="{Binding PropertyName,
                                                Mode=TwoWay,
                                                UpdateSourceTrigger=PropertyChanged}" />
                        <TextBlock Foreground="Blue"
                                   Text="As" />
                        <Grid Margin="7,0">
                            <ComboBox x:Name="cboPropertyType"
                                      Width="317"
                                      MaxWidth="317"
                                      Focusable="False"
                                      Loaded="CboPropertyType_Loaded" />
                            <TextBox Width="300"
                                     Margin="0,0,17,0"
                                     Foreground="Blue"
                                     Text="{Binding PropertyType,
                                                    Mode=TwoWay,
                                                    UpdateSourceTrigger=PropertyChanged}" />
                        </Grid>
                    </StackPanel>

                    <TextBlock Margin="10.5,3.5"
                               Foreground="Blue"
                               Text="Get" />

                    <StackPanel Margin="17.5,3.5"
                                Orientation="Horizontal">
                        <TextBlock Foreground="Blue"
                                   Text="Return" />
                        <TextBox Width="200"
                                 Margin="7,0"
                                 Text="{Binding FieldName,
                                                UpdateSourceTrigger=PropertyChanged}" />
                    </StackPanel>

                    <TextBlock Margin="10.5,3.5"
                               Foreground="Blue"
                               Text="End Get" />

                    <StackPanel Margin="10.5,3.5"
                                Orientation="Horizontal">
                        <TextBlock Margin="0,0,7,0"
                                   Foreground="Blue"
                                   Text="Private"
                                   Visibility="{Binding HasPrivateSetter,
                                                        Converter={StaticResource booleanToVisibilityConverter}}" />
                        <TextBlock Foreground="Blue"
                                   Text="Set(ByVal " />
                        <TextBlock Text="Value " />
                        <TextBlock Foreground="Blue"
                                   Text="As" />
                        <TextBlock Margin="7,0,0,0"
                                   Foreground="Blue"
                                   Text="{Binding PropertyType}" />
                        <TextBlock Text=")" />
                    </StackPanel>

                    <StackPanel Margin="17.5,3.5"
                                Orientation="Horizontal">
                        <TextBlock Text="{Binding FieldName}" />
                        <TextBlock Margin="7,0"
                                   Text="= Value" />
                    </StackPanel>

                    <StackPanel Margin="17.5,3.5"
                                Orientation="Horizontal"
                                Visibility="{Binding IncludeOnPropertyChanged,
                                                     Converter={StaticResource booleanToVisibilityConverter}}">
                        <!--  <Grid Margin="0,0,7,0">  -->
                        <ComboBox x:Name="cboPropertyChangedMethodNames"
                                  MinWidth="150"
                                  MaxWidth="170"
                                  Margin="0,0,7,0"
                                  Focusable="False"
                                  IsSynchronizedWithCurrentItem="True"
                                  Loaded="CboPropertyChangedMethodNames_Loaded"
                                  SelectedValue="{Binding OnPropertyChangedMethodName,
                                                          Mode=TwoWay}" IsEditable="True" />

                        <!--
                            <TextBox Width="150"
                            Margin="0,0,17,0"
                            HorizontalAlignment="Left"
                            VerticalAlignment="Top"
                            Text="{Binding OnPropertyChangedMethodName, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
                        -->
                        <!--  </Grid>  -->

                        <TextBlock Text="(" />
                        <TextBlock Foreground="Maroon"
                                   Text="&quot;" />
                        <TextBlock Foreground="Maroon"
                                   Text="{Binding PropertyName}" />
                        <TextBlock Foreground="Maroon"
                                   Text="&quot;" />
                        <TextBlock Text=")" />
                    </StackPanel>

                    <TextBlock Margin="10.5,3.5"
                               Foreground="Blue"
                               Text="End Set" />

                    <TextBlock Margin="3.5"
                               Foreground="Blue"
                               Text="End Property" />

                    <GroupBox Margin="7">
                        <GroupBox.Header>
                            <TextBlock FontWeight="Bold"
                                       Text="Options" />
                        </GroupBox.Header>
                        <StackPanel>
                            <CheckBox Margin="3.5"
                                      Content="Is Property Public"
                                      IsChecked="{Binding IsPropertyPublic,
                                                          Mode=TwoWay,
                                                          UpdateSourceTrigger=PropertyChanged}" />
                            <CheckBox Margin="3.5"
                                      Content="Is Property ReadOnly"
                                      IsChecked="{Binding IsPropertyReadOnly,
                                                          Mode=TwoWay,
                                                          UpdateSourceTrigger=PropertyChanged}" />
                            <CheckBox Margin="3.5"
                                      Content="Is Setter Private"
                                      IsChecked="{Binding HasPrivateSetter,
                                                          Mode=TwoWay,
                                                          UpdateSourceTrigger=PropertyChanged}" />
                            <CheckBox Margin="3.5"
                                      Content="Include Property Changed Notification"
                                      IsChecked="{Binding IncludeOnPropertyChanged,
                                                          Mode=TwoWay,
                                                          UpdateSourceTrigger=PropertyChanged}" />
                            <CheckBox Margin="3.5"
                                      Content="Implement INotifyPropertyChanged and Provide OnPropertyChanged EventHandler"
                                      IsChecked="{Binding IncludeOnPropertyChangedEventHandler,
                                                          Mode=TwoWay,
                                                          UpdateSourceTrigger=PropertyChanged}" />
                        </StackPanel>
                    </GroupBox>

                </StackPanel>
            </TabItem>
            <TabItem Margin="0"
                     Header="Properties">
                <DockPanel>
                    <TextBlock Margin="7"
                               HorizontalAlignment="Left"
                               VerticalAlignment="Top"
                               DockPanel.Dock="Top"
                               Text="Select the properties to expose on the view model."
                               TextWrapping="Wrap" />
                    <StackPanel DockPanel.Dock="Top"
                                Orientation="Horizontal">
                        <CheckBox x:Name="UseExtendedCheckBox"
                                  Margin="7,0"
                                  Content="Use extended selection mode"
                                  IsChecked="{Binding IsPropertyListInExtendedMode,
                                                      Mode=TwoWay}" />
                        <CheckBox x:Name="SelectAllCheckBox"
                                  Margin="7,0,0,0"
                                  Click="SelectAllCheckBox_Click"
                                  Content="Select all properties"
                                  IsChecked="{Binding AllPropertiesSelected,
                                                      Mode=OneWay}"
                                  IsThreeState="True" />
                    </StackPanel>
                    <StackPanel Margin="7"
                                DockPanel.Dock="Top"
                                Orientation="Horizontal">
                        <TextBlock FontSize="14"
                                   Text="Data model:" />
                        <TextBlock Margin="7,0,0,0"
                                   FontSize="14"
                                   FontWeight="Bold"
                                   Text="{Binding TypeName}" />
                    </StackPanel>
                    <GroupBox Margin="7"
                              DockPanel.Dock="Bottom">
                        <GroupBox.Header>
                            <TextBlock FontWeight="Bold"
                                       Text="Options" />
                        </GroupBox.Header>
                        <StackPanel>
                            <CheckBox Margin="3.5"
                                      Content="Use Hungarian Notation for Private Backing Fields"
                                      IsChecked="{Binding UseHungarianNotationForPrivateFields,
                                                          Mode=TwoWay,
                                                          UpdateSourceTrigger=PropertyChanged}"
                                      IsEnabled="{Binding IsVB}" />
                        </StackPanel>
                    </GroupBox>
                    <Border MinHeight="100"
                            Margin="7,0"
                            BorderBrush="#FFD5DFE5"
                            BorderThickness="1"
                            CornerRadius="5"
                            DockPanel.Dock="Top">
                        <ListBox x:Name="lbProperties"
                                 BorderBrush="{x:Null}"
                                 FontSize="12"
                                 ItemsSource="{Binding Source={StaticResource cvsProperties}}"
                                 SelectionMode="{Binding PropertiesSelectionMode}" Initialized="lbProperties_Initialized">
                            <ListBox.ItemContainerStyle>
                                <Style TargetType="{x:Type ListBoxItem}">
                                    <Setter Property="IsSelected" Value="{Binding IsSelected, Mode=TwoWay}" />
                                    <!--
                                        <Style.Triggers>
                                        <Trigger Property="IsSelected"
                                        Value="True">
                                        <Setter Property="Background"
                                        Value="CornflowerBlue" />
                                        </Trigger>
                                        </Style.Triggers>
                                    -->
                                </Style>
                            </ListBox.ItemContainerStyle>
                            <ListBox.ItemTemplate>
                                <DataTemplate>
                                    <TextBlock Margin="3.5,2"
                                               Text="{Binding FullName}" />
                                </DataTemplate>
                            </ListBox.ItemTemplate>
                        </ListBox>
                    </Border>

                </DockPanel>
            </TabItem>
            <TabItem Margin="0"
                     HorizontalAlignment="Left"
                     VerticalAlignment="Top"
                     Header="Commands">
                <!--
                    <GroupBox VerticalContentAlignment="Stretch">
                    <GroupBox.Header>
                    <TextBlock FontWeight="Bold"
                    Text="Commands" />
                    </GroupBox.Header>
                -->
                <DockPanel>
                    <TextBlock Margin="7"
                               DockPanel.Dock="Top">
                        Add commands for use by the view model.
                    </TextBlock>
                    <StackPanel Margin="7,0,7,7"
                                HorizontalAlignment="Left"
                                DockPanel.Dock="Top"
                                Orientation="Horizontal">
                        <Button Height="25"
                                HorizontalAlignment="Left"
                                VerticalAlignment="Top"
                                Click="BtnAddCommand_Click"
                                Content="Add Command"
                                Padding="4,1" />
                        <Button Height="25"
                                Margin="7,0,0,0"
                                HorizontalAlignment="Left"
                                VerticalAlignment="Top"
                                Click="BtnDeleteCommand_Click"
                                Content="Delete Selected"
                                IsEnabled="{Binding DeleteCommandEnabled}"
                                Padding="4,1" />
                        <CheckBox Margin="14,5,7,7"
                                  Content="Use extended selection mode"
                                  IsChecked="{Binding IsPropertyListInExtendedMode,
                                                      Mode=TwoWay}" />
                    </StackPanel>


                    <Border Margin="7,0,7,7"
                            BorderBrush="#FFD5DFE5"
                            BorderThickness="1"
                            CornerRadius="5"
                            DockPanel.Dock="Top">
                        <ListBox x:Name="commandsList"
                                 Height="342"
                                 AlternationCount="1"
                                 Background="White"
                                 BorderThickness="0"
                                 ItemContainerStyle="{StaticResource alternatingWithTriggers}"
                                 ItemsSource="{Binding CommandsCollection}"
                                 SelectionChanged="ListBox_SelectionChanged"
                                 SelectionMode="{Binding PropertiesSelectionMode}" />
                    </Border>
                    <!--  BMK: CommandsCollection List  -->
                </DockPanel>
                <!--  </GroupBox>  -->
            </TabItem>
        </TabControl>
    </DockPanel>
</Window>